const router = require('express').Router()
const fs = require('fs')
const path = require('path')

// 播放视频
router.get('/video', async function (req, res,) {
    var videoName = req.query.name;
    res.writeHead(200, { 'Content-Type': 'video/mp4' });
    fs.createReadStream('../back/video/' + videoName + '.mp4').pipe(res);//.pipe(res); 输入到客户端
})

// 播放音频
router.get('/air', function (req, res, next) {
    res.sendFile(path.join(__dirname, '../music/' + req.query.music));
})


module.exports = router;
